package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.entity.OverflowListGoods;
import com.atguigu.jxc.service.OverflowListGoodsService;
import com.atguigu.jxc.service.OverflowListService;
import com.atguigu.jxc.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/overflowListGoods")
public class OverflowListGoodsController {

    @Autowired
    private OverflowListService overflowListService;

//    @Autowired
//    private OverflowListGoodsService overflowListGoodsService;


    @PostMapping("/save")
    public ServiceVO save(OverflowList overflowList, String overflowListGoodsStr) {
        overflowListService.save(overflowList, overflowListGoodsStr);
        return new ServiceVO(100, "添加成功");
    }

    @PostMapping("/list")
    public R list(String sTime, String eTime) {
        List<OverflowList> overflowListList = overflowListService.list(sTime, eTime);
        return R.ok().put("rows",overflowListList);
    }

    @PostMapping("/goodsList")
    public R goodsList(Integer overflowListId) {
        List<OverflowListGoods> overflowListGoods = overflowListService.goodsList(overflowListId);
        return R.ok().put("rows",overflowListGoods);
    }
}
